<?php 
class Sqlite extends SQLite3
{
    private $outdata;

	function __construct($name="menu.db3")
    {
		$config = Config::getInstance();
        $path = $config->getConfig("sqlite3");
		$this->open($path."/".$name);
	}

    public function q($query){
        $ret = $this->query($query);
        if(!$ret){
            return $this->lastErrorMsg();
        } else {
            $this->outdata = $ret;
            return false;
        }
    }
    public function count($query){
        $ret = $this->query($query);
        if(!$ret){
            return 0;
        } else {
            if($row = $ret->fetchArray(SQLITE3_ASSOC)){
                return $row['cc'];
            }else{
                return 0;
            }
        }
    }

    public function e($sql){
        $ret = $this->exec($sql);
        if(!$ret){
            return $this->lastErrorMsg();
        } else {
            return false;
        }
    }
    public function c(){
        return $this->changes();
    }

    public function next(){
        return $this->outdata->fetchArray(SQLITE3_ASSOC);
    }
}